//
//  UIImage+GHY__Watermark.m
//  Camera
//
//  Created by aaaaaa on 16/8/19.
//  Copyright © 2016年 葛海一. All rights reserved.
//

#import "UIImage+GHY__Watermark.h"
#import "NSString+GHY_Width.h"

@implementation UIImage (GHY__Watermark)

- (UIImage *)addText:(UIImage *)img text:(NSString *)mark withRect:(CGRect)rect {
    
    int w = img.size.width;
    int h = img.size.height;
    
    UIGraphicsBeginImageContext(img.size);
    [[UIColor redColor] set];
    
    
    [img drawInRect:CGRectMake(0, 0, w, h)];
    
    CGFloat width = [NSString getTextHeight:mark withWidth:34 withFontSize:34];

    NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:34], NSFontAttributeName,[UIColor whiteColor] ,NSForegroundColorAttributeName,nil];
    [mark drawInRect:CGRectMake(w - width, h - rect.size.height * 2, width, rect.size.height * 2) withAttributes:dic];
    
    UIImage *aimg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return aimg;
}

//- (UIImage *)tailoring{
//    
//}

@end
